import router from './index';
import store from '@/store/index';
import session from '@/toolset/session-storage/session';

let token;
router.beforeEach((to, from, next) => {
  token = localStorage.getItem('token');
  // app.actionFromJs('nihoa')
  //  已经登录过
  if (token) {
    next();
  } else {
    // 免登录页面
    if (
      ['login', 'register', 'home', 'shcp_detail', 'team'].indexOf(to.name) !==
      -1
    ) {
      next();
    } else {
      next('/login');
    }
  }
});

export default router;
